/**
 * createUser:曾维录
 * FileName: BaseException
 * Author:   14562
 * Date:     2019/12/21 11:37
 * Description: 全局异常
 */
package com.javatom.notes.common.exception;


import com.javatom.notes.common.enums.HttpReponseCodeEnum;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

public class BaseException extends RuntimeException implements Serializable {

    private static final long serialVersionUID = 12312312344534211L;

    @Setter
    @Getter
    private String msg;

    @Setter
    @Getter
    private String code = "500";

    public BaseException(String msg) {
        super(msg);
        this.msg = msg;
    }
    public BaseException(HttpReponseCodeEnum httpReponseCodeEnum) {
        super(httpReponseCodeEnum.getDesc());
        this.msg = httpReponseCodeEnum.getDesc();
        this.code = httpReponseCodeEnum.getCode();
    }
    public BaseException(HttpReponseCodeEnum httpReponseCodeEnum, Object... args) {
        super(String.format(httpReponseCodeEnum.getDesc(), args));
        this.code = httpReponseCodeEnum.getCode();
    }

    public BaseException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public BaseException(String msg, String code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public BaseException(String msg, String code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }


}
